<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>44速度曲线-步长实现打字机效果</title>
    <style>
        div {
            overflow: hidden;
            white-space: nowrap;
            font-size: 20px;
            width: 0;
            height: 30px;
            background-color: lightcoral;
            /* animation: w 4s linear forwards; */
            animation: w 4s steps(12) forwards;
            margin: 10px 0;
        }
        
        .box2 {
            animation-delay: 4s;
        }
        
        @keyframes w {
            0% {
                width: 0;
            }
            100% {
                width: 240px;
            }
        }
    </style>
</head>

<body>
    <div>日暮苍山远，天寒白屋贫。</div>
    <div class="box2">柴门闻犬吠，风雪夜归人。</div>
</body>

</html>